package action

import (
	"chat-room/client/global"
	"chat-room/common"
	"encoding/json"
	"fmt"
)

type Keep struct {

}
func (that *Keep) handel(){
	functionsEx := &common.Functions{}
	for {
		msg, err := functionsEx.ReadMsg(global.Conn)
		if err != nil {
			fmt.Printf("functionsEx.ReadMsg:%v\n",err)
			return
		}
		if msg.Type == common.SystemMsgType {
			//如果是系统消息
			var SystemMsgEx  = &common.SystemMsg{}
			err = json.Unmarshal([]byte(msg.Data),SystemMsgEx)
			if err != nil {
				fmt.Printf("functionsEx.ReadMsg:%v\n",err)
				return
			}
			fmt.Println(SystemMsgEx.Info)
		}
		if msg.Type == common.GetOnlineUsersResponseMsgType {
			fmt.Println(msg.Data)
		}
		if msg.Type == common.MassMessageResponseMsgType {
			fmt.Println(msg.Data)
		}
		if msg.Type == common.MassMessageSuccessResponseMsgType {
			fmt.Println("发送成功")
		}
	}
}
